package com.currency.mall.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.currency.mall.R;
import com.currency.mall.entity.OptimalOrderBean;
import com.mifengs.commonbase.util.ImageLoadUtil;

import java.util.List;

/**
 * Created by Administrator on 2018/12/5.
 */

public class HotTradedapter extends BaseQuickAdapter<OptimalOrderBean.OptimalOrderInfo, BaseViewHolder> {

    public HotTradedapter(@Nullable List<OptimalOrderBean.OptimalOrderInfo> data, Context context) {
        super(R.layout.item_hot_trade, data);
    }

    @Override
    protected void convert(BaseViewHolder helper,OptimalOrderBean.OptimalOrderInfo orderInfo) {
        if(!TextUtils.isEmpty(orderInfo.getUserName())){
            String maskNumber = orderInfo.getUserName().substring(0,3)+"****"+orderInfo.getUserName().substring(7,orderInfo.getUserName().length());
            helper.setText(R.id.tv_user_phone,maskNumber);
        }
        helper.setText(R.id.tv_shares_name,orderInfo.getSharesName());
        TextView rate = helper.getView(R.id.tv_profit_rate);
        rate.setText(orderInfo.getYield()+"%");
        rate.setTextColor(Color.parseColor("#E51C23"));
        helper.setText(R.id.tv_buy_price,orderInfo.getBeginSum());
        helper.setText(R.id.tv_sell_price,orderInfo.getEndSum());
        ImageView imageView = helper.getView(R.id.iv_head);
        if(!TextUtils.isEmpty(orderInfo.getHeadImg())){
            ImageLoadUtil.displayImage(mContext,orderInfo.getHeadImg(),imageView);
        }
    }
}
